﻿namespace Numbrella.Client.Common
{
	using System;
	using System.Globalization;

	public class Logger
	{
		static Logger()
		{
			Instance = new Logger();
		}

		private Logger()
		{
			this.LogRecords = new SimpleMultithreadedObservableCollection<string>();
		}

		public static Logger Instance { get; private set; }

		public SimpleMultithreadedObservableCollection<string> LogRecords { get; private set; }

		public void AddRecord(string format, params object[] arg)
		{
			this.AddRecord(String.Format(CultureInfo.CurrentCulture, format, arg));
		}

		public void AddRecord(string message)
		{
			lock (this.LogRecords)
			{
				this.LogRecords.Add(string.Format(CultureInfo.CurrentCulture, "{0}   {1}", DateTime.Now, message));
			}
		}

		public void Clear()
		{
			lock (this.LogRecords)
			{
				this.LogRecords.Clear();
			}
		}
	}
}